package cn.wh.beans;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * @author: wh
 * @create: 2022-08-19 09:31
 * @description
 **/
public class PropertyValues {

    private final List<PropertyValue> propertyValueList = new ArrayList<>();

    /**
     * 添加属性值
     * @param propertyValue
     */
    public void addPropertyValue(PropertyValue propertyValue) {
        propertyValueList.add(propertyValue);
    }

    /**
     * 获取单个属性值对
     * @return
     */
    public PropertyValue[] getPropertyValues() {
        return this.propertyValueList.toArray(new PropertyValue[0]);
    }

    /**
     * 根据name 获取属性值
     * @param name
     * @return
     */
    public PropertyValue getPropertValue(String name) {
        return this.propertyValueList.stream()
                .filter(t -> t.getName() == name)
                .findFirst()
                .orElse(null);
    }

}
